package com.tlgen.zero.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtils {

    public static String cap(String s) {
        return s.substring(0, 1).toUpperCase().concat(s.substring(1));
    }

    public static String uncap(String s) {
        return s.substring(0, 1).toLowerCase().concat(s.substring(1));
    }

    /**
     * 获取简单类名, 如 com.tlgen.spring.service.SysUserService 获取到 SysUserService
     *
     * @param className
     * @return
     */
    public static String getSimpleClassName(String className) {
        return className.substring(className.lastIndexOf(".") + 1);
    }

    public static String getIndentation(String str) {
        Pattern pattern = Pattern.compile("^\\s*");
        Matcher matcher = pattern.matcher(str);
        if (matcher.find()) {
            return matcher.group();
        }
        return "";
    }

}
